<template>
  <div class="course">
    <div class="course_title">
      <p style="margin-right: 20px">{{ routerName }}</p>
    </div>
    <div class="course_synopsis_content">
      <h1>{{courseData.title}}</h1>
      <p class="course_synopsis_content_time">发布时间：{{courseData.createdAt}}</p>
      <div class="course_synopsis_content_paragraph">
        <p v-html="courseData.content"></p>
      </div>
    </div>
  </div>
</template>

<script>
import { findCourseById } from "@/api/course";
export default {
  name: "index",
  data() {
    return {
      routerName: "",
      courseData: {},
    };
  },
  created() {
    this.routerName = this.$route.query.routerName;
  },
  mounted() {
    this.findCourseById();
  },
  methods: {
    findCourseById() {
      findCourseById(this.$route.query.courseId).then((response) => {
        if (response.data.code === 20000) {
          this.courseData = response.data.results;
        }
      });
    },
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.course {
  color: #333;
  .course_list {
    padding: 0 30px;
    font-weight: bold;
    color: #333;
    background: white;
    height: 40px;
    line-height: 40px;
    border: 1px solid #f1f1f1;
    cursor: pointer;
    &:hover {
      color: #0a7b19;
      background: #f4fff6;
    }
  }
  .course_title {
    margin-top: 20px;
    height: 40px;
    background: #f1f1f1;
    text-align: right;
    line-height: 40px;
    font-weight: bold;
    font-size: 21px;
    color: #0a7b19;
  }
  .course_synopsis_content {
    margin-top: 40px;
    margin-bottom: 110px;
    h1 {
      width: 100%;
      text-align: center;
    }
    .course_synopsis_content_time {
      margin-top: 25px;
      font-size: 12px;
      width: 100%;
      text-align: center;
    }
    .course_synopsis_content_paragraph {
      margin-top: 30px;
      font-size: 14px;
      line-height: 24px;
    }
  }
}
</style>